﻿using System;
using System.IO;
using System.Web;

namespace Meotom.Upload.v2.Data
{
    public class Logging
    {
        public void WriteLog(string sErrMsg, string fileError)
        {
            var sLogFormat = DateTime.Now + " ==> ";

            var sYear = DateTime.Now.Year.ToString();
            var sMonth = DateTime.Now.Month.ToString();
            var sDay = DateTime.Now.Day.ToString();

            var sPathName = HttpContext.Current.Server.MapPath("~/Logging/Log_" + sDay + "-" + sMonth + "-" + sYear + ".justin");

            if (sErrMsg == "Thread was being aborted.") return;

            using (var sw = new StreamWriter(sPathName, true))
            {
                sw.WriteLine(sLogFormat + sErrMsg + " ==> " + fileError + " ==> " + HttpContext.Current.Request.UserHostAddress);
            }
        }

    }
}